<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>美嘉饲料</title>
<link rel="stylesheet" href="/m/css/style.css">
<script type="text/javascript" src="<%=basePath%>skin/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="<%=basePath%>m/js/common.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta http-equiv="Expires" CONTENT="-1">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
<script language="javascript">
$().ready(function(){
	 $("#add").click(function(){
		 window.location.href="<%=basePath%>m/member/receiver/add.shtml";
	 });
	 
	 var $delete = $("a.delete");
	 $delete.click(function(){
		 if(confirm("确定要删除收货地址吗？")) {
			 var $this = $(this);
			 var $tr = $this.parent().parent().parent();
			 var id = $tr.find("input[name='id']").val();
			 $.ajax({
					url: "<%=basePath%>member/receiver/delete.shtml",
					type: "POST",
					data: {id: id},
					cache: false,
					beforeSend: function() {
						$delete.prop("disabled", true);
					},
					success: function(data) {
						var success = data.success;
						if (success == "true") {
							alert("收货地址删除成功");
						} else {
							alert("收货地址删除失败");
						}
						location.reload(true);
					},
					complete: function() {
						$delete.prop("disabled", false);
					}
				});
		 }
		 return false;
	 });
});
</script>
</head>
<body>
	<c:import url="/m/layouts/top.jsp" />
	<a name="top"></a>
	<!--header-->
	<header>
		<div class="header">
			<a href="/m/member/index.shtml" class="header-a-back"><span>返回</span></a>
			<a href="/m/index.html" class="header-a-home"><span>首页</span></a>
			<h2>收货地址</h2>
		</div>
	</header>
	<a href="javascript:;" data-addaddress="true" class="textlink fl" id="add">添加收货地址</a>
	<div class="clear"></div>
	<c:forEach items="${receivers }" var="receiver">
		<div class="addr-list">
			<div class="divaddr">
				<p>
					<input type="hidden" name="id" value="${receiver.id}" />
					${receiver.consignee }<span class="addr_tel">${receiver.phone }</span>
				</p>
				<p class="clear"></p>
				<p>${receiver.address }</p>
				<p>${receiver.zipCode }</p>
			</div>
			<div class="addr_ope">
				<div class="fl">
					<a href="#" data-address="del" class="delete"><span class="del"></span>删除</a>
				</div>
				<div class="fr">
					<a href="/m/member/receiver/edit.shtml?id=${receiver.id }"><span class="edi"></span>修改</a>
				</div>
			</div>
		</div>
		<div class="clear"></div>
	</c:forEach>
	<c:import url="/m/layouts/foot.jsp" />
</body>
</html>
